#include <iostream>
#include <vector>

using namespace std;
vector<int> productExceptSelf(vector<int>& nums) {
    int n = nums.size();
    vector<int> prevfix(n + 10, 1);
    vector<int> suffix(n + 10, 1);

    for (int i = 1; i <= n; ++i)
    {
        prevfix[i] = prevfix[i - 1] * nums[i - 1];
    }

    for (int i = n; i > 0; --i)
    {
        suffix[i] = suffix[i + 1] * nums[i - 1];
    }

    vector<int> ret(n, 0);
    for (int i = 1; i <= n; ++i)
        ret[i - 1] = prevfix[i - 1] * suffix[i + 1];

    return ret;
}

int main()
{
    vector<int> nums = { 1,2,3,4 };
    productExceptSelf(nums);
	return 0;
}